package com.ruoyi.energy.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.energy.domain.NyMeterAccount1;
import com.ruoyi.energy.service.INyMeterAccount1Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 仪台账资产Controller
 *
 * @author cjie
 * @date 2022-02-25
 */
@Api(tags = " 仪台账资产")
@RestController
@RequestMapping("/nyMeterAccount1")
public class NyMeterAccount1Controller extends BaseController {
    @Autowired
    private INyMeterAccount1Service nyMeterAccount1Service;

    /**
     * 查询仪台账资产列表
     */
    @ApiOperation(value="查询仪台账资产列表", notes="查询仪台账资产列表")
    @PreAuthorize(hasPermi = "energy:nyMeterAccount1:list")
    @GetMapping("/list")
    public TableDataInfo list(NyMeterAccount1 nyMeterAccount1) {
        startPage();
        List<NyMeterAccount1> list = nyMeterAccount1Service.selectNyMeterAccount1List(nyMeterAccount1);
        return getDataTable(list);
    }

    /**
     * 导出仪台账资产列表
     */
    @ApiOperation(value="导出仪台账资产列表", notes="导出仪台账资产列表")
    @PreAuthorize(hasPermi = "energy:nyMeterAccount1:export")
    @Log(title = "仪台账资产", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public void export(HttpServletResponse response, NyMeterAccount1 nyMeterAccount1) throws IOException {
        List<NyMeterAccount1> list = nyMeterAccount1Service.selectNyMeterAccount1List(nyMeterAccount1);
        ExcelUtil<NyMeterAccount1> util = new ExcelUtil<NyMeterAccount1>(NyMeterAccount1.class);
        util.exportExcel(response, list, "仪台账资产数据");
    }
    /**
     * 获取仪台账资产详细信息
     */
    @ApiOperation(value="获取仪台账资产详细信息", notes="获取仪台账资产详细信息")
    @PreAuthorize(hasPermi = "energy:nyMeterAccount1:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(nyMeterAccount1Service.selectNyMeterAccount1ById(id));
    }

    /**
     * 新增仪台账资产
     */
    @ApiOperation(value="新增仪台账资产", notes="新增仪台账资产")
    @PreAuthorize(hasPermi = "energy:nyMeterAccount1:add")
    @Log(title = "仪台账资产", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NyMeterAccount1 nyMeterAccount1) {
        return toAjax(nyMeterAccount1Service.insertNyMeterAccount1(nyMeterAccount1));
    }

    /**
     * 修改仪台账资产
     */
    @ApiOperation(value="修改仪台账资产", notes="修改仪台账资产")
    @PreAuthorize(hasPermi = "energy:nyMeterAccount1:edit")
    @Log(title = "仪台账资产", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NyMeterAccount1 nyMeterAccount1) {
        return toAjax(nyMeterAccount1Service.updateNyMeterAccount1(nyMeterAccount1));
    }

    /**
     * 删除仪台账资产
     */
    @ApiOperation(value="删除仪台账资产", notes="删除仪台账资产")
    @ApiImplicitParam(name = "ids", value = "仪台账资产ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "energy:nyMeterAccount1:remove")
    @Log(title = "仪台账资产", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(nyMeterAccount1Service.deleteNyMeterAccount1ByIds(ids));
    }
}
